import 'package:casdon/core/logger/log.dart';
import 'package:casdon/core/network/business_exception.dart';
import 'package:casdon/modules/lifeCircle/data/api/life_topic_list_api.dart';
import 'package:casdon/modules/lifeCircle/data/repository/life_repository.dart';

class TopicRecommendListUsecase {
  final LifeRepository _repository;

  const TopicRecommendListUsecase(this._repository);

  Future<ResponseLifeTopicListApi> execute({
    required int pageNum,
    required int pageSize
  }) async {
    try {
      var ret = await _repository.getTopicRecomendList(pageNum, pageSize);
      ret ??= ResponseLifeTopicListApi(0, []);
      return ret;
    } on BusinessException {
      rethrow;
    } catch (e) {
      Log.e("TopicRecommendListUsecase 失败", e.toString(), StackTrace.current);
      throw Exception("TopicRecommendListUsecase 失败");
    }
  }
}